package com.hutao.sso.controller.authority;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpSession;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.hutao.sso.pojo.user.Users;
import com.hutao.sso.service.authority.AuthorityService;
import com.hutao.sso.util.AuthorityTree;

@RequestMapping("/authority")
@Controller
public class AuthorityContorller {
	
	@Autowired
	private AuthorityService authorityService;
	
	//查询所有的权限
	@GetMapping(value = "/findAuthorityList")
	@ResponseBody
	public Map<String, Object> findAuthorityList(String roleId, HttpSession session) {
		Map<String, Object> results = new HashMap<>();
		Map<String, Object> params = new HashMap<>();
		
		Users user = (Users)session.getAttribute("current_user");
		params.put("medicalMainstayId", user!=null?user.getMedicalMainstayId():null);
		params.put("roleId", roleId);
		
		List<AuthorityTree> authorityList = authorityService.findAuthoritysList(params);
		results.put("authorityList", authorityList);
		return results;
	}

}
